package com.basics.framework.web.domain;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

@ApiModel("分页数据")
public class PageResponse<T> implements Serializable {
    private static final long serialVersionUID = 679979078949947434L;
    @ApiModelProperty("总数")
    private long total = 0L;
    @ApiModelProperty("当前页")
    private long current = 1L;
    @ApiModelProperty("分页数")
    private long size = 0L;
    @ApiModelProperty("当前分页总页数")
    private long pages = 0L;
    @ApiModelProperty("列表数据")
    private List<T> records = Collections.emptyList();

    public PageResponse(IPage<T> page) {
        this.total = page.getTotal();
        this.current = page.getCurrent();
        this.pages = page.getPages();
        this.size = page.getSize();
        this.records = page.getRecords();
    }

    public PageResponse() {
    }

    public long getTotal() {
        return this.total;
    }

    public long getCurrent() {
        return this.current;
    }

    public long getSize() {
        return this.size;
    }

    public long getPages() {
        return this.pages;
    }

    public List<T> getRecords() {
        return this.records;
    }

    public void setTotal(final long total) {
        this.total = total;
    }

    public void setCurrent(final long current) {
        this.current = current;
    }

    public void setSize(final long size) {
        this.size = size;
    }

    public void setPages(final long pages) {
        this.pages = pages;
    }

    public void setRecords(final List<T> records) {
        this.records = records;
    }

}
